﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SuYuanSystem.Applications;
using SuYuanSystem.Domain;
using SuYuanSystem.WebApi.MedialRs.Commands.Enterprises;

namespace SuYuanSystem.WebApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class EnterpriseController : ControllerBase
    {
        public EnterpriseController(IMediator mediator)
        {
            Mediator = mediator;
        }


        public IMediator Mediator { get; }
        /// <summary>
        /// 中介者添加企业
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<object>> EnterpriseAdd(EnterpriseCommands command)
        {
            return await Mediator.Send(command);
        }
        /// <summary>
        /// 中介者查询企业
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<Enterprise>> EnterpriseQuery()
        {
            EnterpriseQueryCommands command = new EnterpriseQueryCommands();
            return await Mediator.Send(command);
        }
    }
}
